package com.wpd.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.bo.ResultMsg;
import com.wpd.bo.WpdUser;
import com.wpd.service.IWpdUserService;

@Controller
@RequestMapping("/login")
public class LoginController {

	@Autowired
	private IWpdUserService wpdUserService;
	
	/**
	 * 登录
	 * @return
	 */
	@RequestMapping(value = "/userLogin")
	@ResponseBody
	public ResultMsg userLogin(HttpSession session, @ModelAttribute WpdUser wpdUser){
		//登录
		wpdUser = wpdUserService.userLogin(wpdUser);
		if(wpdUser == null){
			return new ResultMsg("1", "用户名密码错误");
		}
		session.setAttribute("user_info",wpdUser);
		ResultMsg result = new ResultMsg("0", "成功");
		result.setData(wpdUser);
		return result;
	}
}
